/**
 * 一个树，三种类型的节点：PSC。
 * 要求切最少的次数，使得任意P和S不相连。
 * 设Pi是i子树内，i节点与P相连时的最少切割次数
 * Ui是i子树内，i节点与S相连的最少切割次数
 * Ui = SIGMA{min(Uj, Pj + 1), j是i的儿子}
 * Pi = SIGMA{min(Pj, Uj + 1), j是i的儿子}
 * 即如果父子同类，则无需切割，否则得加一刀
 * 对于P节点可以认为Ui无穷大，S节点则Pi无穷大 
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int const INF = 0x3F8F9FAF;

int N;
vector<vi> G;
string S;

vector<int> P, U;

void dfs(int u, int p){
    if('P' == S[u]){
		auto & tmp = P[u];
		tmp = 0;
		for(auto v : G[u]){
			if(v == p) continue;
			dfs(v, u);
	    
		    if('P' == S[v]){
                tmp += P[v];
			}else if('S' == S[v]){
                tmp += U[v] + 1;
			}else{
                tmp += min(P[v], U[v] + 1); 
			}
		}		
	}else if('S' == S[u]){
		auto & tmp = U[u];
		tmp = 0;

		for(auto v : G[u]){
			if(v == p) continue;
			dfs(v, u);
	
	        if('P' == S[v]){
                tmp += P[v] + 1;
			}else if('S' == S[v]){
                tmp += U[v]; 
			}else{
				tmp += min(U[v], P[v] + 1); 
			}
		}			
	}else{
		auto & utmp = U[u];
		auto & ptmp = P[u];
		utmp = ptmp = 0;

		for(auto v : G[u]){
			if(v == p) continue;
			dfs(v, u);
	
	        if('P' == S[v]){
                ptmp += P[v];
				utmp += P[v] + 1;
			}else if('S' == S[v]){
                utmp += U[v];
				ptmp += U[v] + 1;
			}else{
				utmp += min(U[v], P[v] + 1);
				ptmp += min(P[v], U[v] + 1); 
			}
		}			
	}
	return;

}

int proc(){
    P.assign(N + 1, INF);
	U.assign(N + 1, INF);

	dfs(1, 0);
	return min(P[1], U[1]);
}

void work(){
    cin >> N;
    G.assign(N + 1, {});
	for(int a,i=2;i<=N;++i){
        cin >> a;
		G[a].push_back(i);
		G[i].push_back(a);
	}
	cin >> S;
	S = " " + S;
	cout << proc() << "\n";
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--) work();
    return 0;
}